<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath(); %>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>垫款规则维护</title>
<jsp:include page="../../import.jsp" flush="true" />
	<style>
		.ui-textbox{
			position: relative;
			border: 1px solid #e9e9e9;
			height: 18px;
			line-height: 18px;
			width: 130px;
			border-radius: 4px;
		}
	</style>
</head>

<body class="iframeBody">
	<div class="Wrapper">
		<div id="pageInTab" class="pageInTab">
			<div class="searchArea">
				<form id="searchBar">
					<div class="fieldset1 clearFix">
						<div class="fieldBox col_33" id="searchCstNmId">
							<div class="label">规则名称</div>
							<div class="field">
								<input name="ruleNm" id="ruleNmSearch" type="text" class="ui-textbox"
									value="">
							</div>
						</div>
						
						<div class="fieldBox col_33" id="searchCstNmId">
							<div class="label">再融资项目</div>
							<div class="field">
								<input name="refPrjNm" id="refPrjNmSearch" type="text"
									class="ui-textbox" value="">
							</div>
						</div>
						<div class="clearFix"></div>
						<div class="btnsBox">
							<span id="searchBtn" class="sq-button sq-button-round">查询</span>
							<span id="addBtn" class="sq-button sq-button-round"> 新增</span>
						</div>
					</div>
				</form>
			</div>
			<div id="grid" class="sq-grid"></div>
		</div>
		
		<!-- 添加 规则 start  -->
		<div id="addRule_Html" style="display:none">
	            <form id="dk_rule_info_form">
	                <div class="fieldset1 tabel_col clearFix">
	                	<div class="fieldBox col_100">
	                		基本信息：
	                    </div>
	                    <div class="fieldBox col_100">
	                        <div class="label">规则名称</div>
	                        <div class="field">
	                       		<input name="ruleNm" id="ruleNm" type="text" class="ui-textbox">
	                        </div>
	                    </div>

						<div class="fieldBox col_50">
							<div class="label">垫款类型</div>
							<div class="field">
								<select name="dkStyleCd" id="dkStyleCd" class="ui-textbox">
									<option value="" selected="selected">--请选择--</option>
									<option value="1">明垫</option>
									<option value="0">暗垫</option>
								</select>
							</div>
						</div>

	                    <div class="fieldBox col_50">
	                        <div class="label">再融资项目</div>
	                        <div class="field">
	                        	<input name="refPrjId" id="refPrjId" type="hidden" class="ui-textbox">
	                        	<input name="jgNoId" id="jgNoId" type="hidden" class="ui-textbox">
	                        	<input name="refPrjNm" id="refPrjNm" readonly= "true" type="text" class="ui-textbox">
	                        </div>
	                    </div>

						<div class="fieldBox col_50">
	                        <div class="label">收款账户</div>
	                        <div class="field">
	                       		 <select name="accTypCd" id="accTypCd" class="ui-textbox">
	                                 <option value="" selected="selected">--请选择--</option>
	                                 <option value="1">承租人账户</option>
	                                 <option value="2">我司账户</option>
	                                 <option value="3">机构账户</option>
	                                 <option value="4">无</option>
	                             </select>
	                        </div>
	                    </div>

	                   <div class="fieldBox col_50">
	                        <div class="label">账户信息</div>
	                        <div class="field">

	                        	<!-- 我司账户 -->
	                        	<input name="accId-2" id="accId-2-Id" type="hidden" class="ui-textbox">
	                        	<input name="accNum-2" id="accId-2" type="text" readonly= "true" style="display:none" class="ui-textbox">

	                        	<!-- 结构账户 -->
	                        	<input name="accId-3" id="accId-3-Id" type="hidden" class="ui-textbox">
	                        	<input name="accNum-3" id="accId-3" type="text" readonly= "true" style="display:none" class="ui-textbox">

	                        	<input name="accountTypCd" id="add_accTypCd" type="hidden" class="ui-textbox">
	                        	<input name="bkNm" id="add_bkNm" type="hidden" class="ui-textbox">
	                        	<input name="bkNo" id="add_bkNo" type="hidden" class="ui-textbox">
	                        	<input name="rcptUnt" id="add_rcptUnt" type="hidden" class="ui-textbox">
	                        </div>
	                    </div>

	                   <div class="fieldBox col_50">
	                        <div class="label">最高垫款次数（累计）</div>
	                        <div class="field">
	                       	 	<input name="totalMaxQty" id="totalMaxQty" type="text" class="ui-textbox">
	                       	 	<input type="checkbox" name="totalMaxQtyCh" id="totalMaxQtyCh"/> 无限制
	                        </div>
	                    </div>

	                    <div class="fieldBox col_50">
	                        <div class="label">最高垫款次数（单资产）</div>
	                        <div class="field">
	                        	<input name="singleMaxQty" id="singleMaxQty" type="text" class="ui-textbox">
	                        	<input type="checkbox" name="singleMaxQtyCh" id="singleMaxQtyCh"/> 无限制
	                        </div>
	                    </div>

						<div class="fieldBox col_50">
	                        <div class="label">赎回执行</div>
	                        <div class="field">
	                        		<select name="ransomExecCd" id="ransomExecCd" class="ui-textbox">
	                                 <option value="" selected="selected">--请选择--</option>
	                                 <option value="1">标记赎回</option>
	                                 <option value="2">生成小贷账单</option>
	                             </select>
	                        </div>
	                    </div>


						<div class="fieldBox col_50">
	                        <div class="label">是否资管业务</div>
	                        <div class="field">
	                        		<select name="isAssBiz" id="isAssBiz" class="ui-textbox">
	                                 <option value="" selected="selected">--请选择--</option>
	                                 <option value="1">是</option>
	                                 <option value="0">否</option>
	                             </select>
	                        </div>
	                    </div>

						<div class="fieldBox col_50" id="searchInsCodeId">
							<div class="label">第三方机构</div>
							<div class="field">
								<select name="thdOrgCd"  id="thdOrgCd" class="ui-textbox">
									<option value="  " selected="selected">--请选择--</option>
									<c:forEach items="${friBaseList}" var="fri">
										<option value="'${fri.insCode}_${fri.id}'">${fri.fundRasInsNm}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">起租日</div>
							<div class="field">
								<input name="lsDtStart" id="lsDtStart" type="text" value="">
								<span>--</span>
								<input name="lsDtEnd" id="lsDtEnd" type="text" value="">
							</div>
						</div>

						<div class="fieldBox col_100">
	                		逾期天数垫款目标：
	                    </div>

						<div class="fieldBox col_50">
	                        <div class="label">起垫逾期天数（含）</div>
	                        <div class="field">
	                        	<input name="startOvedayDays" id="startOvedayDays" type="text" class="ui-textbox">
	                        </div>
	                    </div>
	                     <div class="fieldBox col_50">
	                        <div class="label">最高逾期天数（含）</div>
	                        <div class="field">
	                        	<input name="endOvedayDays" id="endOvedayDays" type="text" class="ui-textbox">
	                        </div>
	                    </div>
	                </div>

	                <div class="btnsBox">
	                        <span id="savePrjBscInfoBtn" class="sq-button sq-button-round">保存</span>
	                        <span id="cancelBtn" class="sq-button sq-button-round">取消</span>
	                </div>
	            </form>
		</div>
		<!-- 添加 规则 end  -->

		<!-- 修改规则弹出框 start  -->
		<div id="changeRule_Html" style="display:none">
		    <form id="changeRule_form">
                <div class="fieldset1 tabel_col clearFix">
                	<div class="fieldBox col_100">
                		基本信息：
                    </div>
                    <div class="fieldBox col_100">
                        <div class="label">规则名称</div>
                        <div class="field">
                       		<input name="ruleNm" id="ruleNmUp" type="text" class="ui-textbox">
                        </div>
                    </div>

					<div class="fieldBox col_50">
						<div class="label">垫款类型</div>
						<div class="field">
							<select name="dkStyleCd" id="dkStyleCdUp" class="ui-textbox">
								<option value="" selected="selected">--请选择--</option>
								<option value="1">明垫</option>
								<option value="0">暗垫</option>
							</select>
						</div>
					</div>

                    <div class="fieldBox col_50">
                        <div class="label">再融资项目</div>
                        <div class="field">
                        	<input name="refPrjId" id="refPrjIdUp" type="hidden" class="ui-textbox">
                        	<input name="jgNoId" id="jgNoIdUp" type="hidden" class="ui-textbox">
                        	<input name="refPrjNm" id="refPrjNmUp" readonly= "true" type="text" class="ui-textbox">
                        </div>
                    </div>

					<div class="fieldBox col_50">
                        <div class="label">收款账户</div>
                        <div class="field">
                       		 <select name="accTypCd" id="accTypCdUp" class="ui-textbox">
                                 <option value="" selected="selected">--请选择--</option>
                                 <option value="1">承租人账户</option>
                                 <option value="2">我司账户</option>
                                 <option value="3">机构账户</option>
								  <option value="4">无</option>
                             </select>
                        </div>
                    </div>

                   <div class="fieldBox col_50">
                        <div class="label">账户信息</div>
                        <div class="field">
                        	<input name="accId-2" id="accId-2-Id-Up" type="hidden" class="ui-textbox">
                        	<input name="accNum-2" id="accId-2-Up" type="text" readonly= "true" style="display:none" class="ui-textbox">

                        	<!-- 机构账户 -->
                       		<input name="accId-3" id="accId-3-Id-Up" type="hidden" class="ui-textbox">
                       		<input name="accNum-3" id="accId-3-Up" type="text" readonly= "true" style="display:none" class="ui-textbox">

                       		<input name="accountTypCd" id="up_accTypCd" type="hidden" class="ui-textbox">
                       		<input name="bkNm" id="up_bkNm" type="hidden" class="ui-textbox">
                       		<input name="bkNo" id="up_bkNo" type="hidden" class="ui-textbox">
                       		<input name="rcptUnt" id="up_rcptUnt" type="hidden" class="ui-textbox">
                        </div>
                    </div>

                   <div class="fieldBox col_50">
                        <div class="label">最高垫款次数（累计）</div>
                        <div class="field">
                       	 	<input name="totalMaxQty" id="totalMaxQtyUp" type="text" class="ui-textbox">
                       	 	<input type="checkbox" name="totalMaxQtyCh" id="totalMaxQtyChUp"/> 无限制
                        </div>
                    </div>

                    <div class="fieldBox col_50">
                        <div class="label">最高垫款次数（单资产）</div>
                        <div class="field">
                        	<input name="singleMaxQty" id="singleMaxQtyUp" type="text" class="ui-textbox">
                        	<input type="checkbox" name="singleMaxQtyCh" id="singleMaxQtyChUp"/> 无限制
                        </div>
                    </div>

					<div class="fieldBox col_50">
                        <div class="label">赎回执行</div>
                        <div class="field">
                        		<select name="ransomExecCd" id="ransomExecCdUp" class="ui-textbox">
                                 <option value="" selected="selected">--请选择--</option>
                                 <option value="1">标记赎回</option>
                                 <option value="2">生成小贷账单</option>
                             </select>
                        </div>
                    </div>

					<div class="fieldBox col_50">
                        <div class="label">是否资管业务</div>
                        <div class="field">
                        		<select name="isAssBiz" id="isAssBizUp" class="ui-textbox">
                                 <option value="" selected="selected">--请选择--</option>
                                 <option value="1">是</option>
                                 <option value="0">否</option>
                             </select>
                        </div>
                    </div>

					<div class="fieldBox col_50" id="searchInsCodeId">
						<div class="label">第三方机构</div>
						<div class="field">
							<select name="thdOrgCd"  id="thdOrgCdUp" class="ui-textbox">
								<option value="  " selected="selected">--请选择--</option>
								<c:forEach items="${friBaseList}" var="fri">
									<option value="'${fri.insCode}_${fri.id}'">${fri.fundRasInsNm}</option>
								</c:forEach>
							</select>
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">起租日</div>
						<div class="field">
							<input name="lsDtStart" id="lsDtStartUp" type="text" class="ui-datepicker" value="">
							<span>--</span>
							<input name="lsDtEnd" id="lsDtEndUp" type="text" class="ui-datepicker" value="">
						</div>
					</div>

					<div class="fieldBox col_100">
                		逾期天数垫款目标：
                    </div>

					<div class="fieldBox col_50">
                        <div class="label">起垫逾期天数（含）</div>
                        <div class="field">
                        	<input name="startOvedayDays" id="startOvedayDaysUp" type="text" class="ui-textbox">
                        </div>
                    </div>
                     <div class="fieldBox col_50">
                        <div class="label">最高逾期天数（含）</div>
                        <div class="field">
                        	<input name="endOvedayDays" id="endOvedayDaysUp" type="text" class="ui-textbox">
                        </div>
                    </div>
                </div>

                <div class="btnsBox">
                        <span id="savePrjBscInfoBtnUp" class="sq-button sq-button-round"><i class="sqBtnIco_10"></i>保存</span>
                        <span id="cancelBtnUp" class="sq-button sq-button-round"><i class="sqBtnIco_14"></i>取消</span>
                </div>
            </form>
		</div>
		<!-- 修改规则弹出框 end  -->

		<!-- 添加项目 start  -->
		<div id="addPrj_Html" class="searchArea" style="display:none">
	    <form id="searchBarPrj">
	        <div class="fieldset1 clearFix">
	         	<div class="fieldBox col_50">
	                <div class="label">再融资项目</div>
	                <div class="field">
	                    <input name="fncprjnm" id="fncprjnm" type="text" class="ui-textbox" />
	                </div>
	                <div style="display: none">
	                </div>
	             </div>
	             <div class="fieldBox col_50">
	                <div class="label">金融机构</div>
	                <div class="field">
	                    <input name="fncinsid" id="fncinsid" type="text" class="ui-textbox" value="" placeholder="请选择"  ltype="combobox">
	                </div>
	                <div style="display: none">
	                </div>
	             </div>
	         </div>
	         
            <div class="clearFix"></div>
            <div class="btnsBox">
               <span id="searchBtnPrj" class="sq-button sq-button-round">查询</span>
               <span id="selectBtnPrj" class="sq-button sq-button-round">选择</span>
            </div>
		 </form>
		 
 		<div id="gridPrj" class="sq-grid"></div>
        </div>
        <!-- 添加项目 end  -->
		
		<!-- 我司账户-银行账号 start  -->
		<div id="addBank_Html" class="searchArea" style="display:none">
	    <form id="searchBar_Bank">
	        <div class="fieldset1 clearFix">
	            <div class="fieldBox">
	                <div class="label">开户行</div>
	                <div class="field">
	                    <input name="bkNm" id="bkNm" type="text" class="ui-textbox" value="">
	                </div>
	            </div>
	            <div class="fieldBox">
	                <div class="label">账号名称</div>
	                <div class="field">
	                    <input name="accNm1" id="accNm1" type="text" class="ui-textbox" value="">
	                </div>
	            </div>
	            
	            <div class="clearFix"></div>
	            <div class="btnsBox">
	                <span id="searchBtn_bank" class="sq-button sq-button-hasicon"><i class="sqBtnIco_1"></i>查询</span>
	                <span id="selectBtn_bank" class="sq-button sq-button-round">选择</span>
	            </div>
	        </div>
	    </form>
	    <div id="grid_bank" class="sq-grid"></div>
	</div>
	<!-- 我司账户-银行账号 end  -->
	
	<!-- 机构账户-银行账号 start  -->
	<div id="addjgBank_Html" class="searchArea" style="display:none">
	    <span id="selectBtn_jg_bank" class="sq-button sq-button-round">选择</span>
	    <div id="jg_grid_bank" class="sq-grid"></div>
	</div>
	<!-- 机构账户-银行账号 end  -->
	</div>
	</div>
	
	<script type="text/javascript">
		var grid = null;
		var grid_bank = null;
		var jg_grid_bank = null;
		var ligerDialogPrj=null;
		var ligerDialogAdd=null;
		var ligerDialogUp=null;
		var ligerDialogBank=null;
		var ligerDialogJgBank=null;
		var isUpdateFlag="";
		var modifyId ="";
		$(function () {
			/****规则列表 js start*******/
			initGrid();//grid
			$("#lsDtStart").ligerDateEditor();
			$("#lsDtStartUp").ligerDateEditor();
			$("#lsDtEndUp").ligerDateEditor();
			$("#lsDtEnd").ligerDateEditor();
		    $("#searchBtn").bind("click",function(){
		         var form = liger.get("searchBar");
		         var data = form.getData();
		         for (name in data){
		            grid.setParm(name,data[name]);
		         };
		        grid.reload();
		    });
			/***规则列表 js end*******/
			
		    /***添加规则js start****/
		    $("#addBtn").bind("click",function(){
			   addBtn();
		    });
		    
		    $("#savePrjBscInfoBtn").bind("click",function(){ 
			   saveDkRuleInfo();
		    });
		    
		    $("#savePrjBscInfoBtnUp").bind("click",function(){ 
			   saveDkRuleInfoUp();
		    });
		    
		    $("#cancelBtn").bind("click",function(){ 
			   cancelDkRuleINfoBtn();
		    });
		    
		    $("#cancelBtnUp").bind("click",function(){ 
			   cancelDkRuleINfoUpBtn();
		    });
		    
		    $("#totalMaxQtyCh").bind("click",function(){ 
			    if($(this).is(':checked')) {
			    	$("#totalMaxQty").val("");
			    	$("#totalMaxQty").attr("disabled","disabled");
	 			}else{
	 				$("#totalMaxQty").removeAttr("disabled");
	 			}
		    });
		    
		    $("#singleMaxQtyCh").bind("click",function(){  
			    if($(this).is(':checked')) {
			    	$("#singleMaxQty").val("");
			    	$("#singleMaxQty").attr("disabled","disabled");
	 			}else{
	 				$("#singleMaxQty").removeAttr("disabled");
	 			}
		    });
		    
		    $("#totalMaxQtyChUp").bind("click",function(){  
		    	if($(this).is(':checked')) {
			    	$("#totalMaxQtyUp").val("");
			    	$("#totalMaxQtyUp").attr("disabled","disabled");
	 			}else{
	 				$("#totalMaxQtyUp").removeAttr("disabled");
	 			} 
			});
		    
		    $("#singleMaxQtyChUp").bind("click",function(){  
		    	if($(this).is(':checked')) {
			    	$("#singleMaxQtyUp").val("");
			    	$("#singleMaxQtyUp").attr("disabled","disabled");
	 			}else{
	 				$("#singleMaxQtyUp").removeAttr("disabled");
	 			}
			});  
		    
		    $("#dkStyleCd").bind("change",function(){
		    	var selVal = $("#dkStyleCd option:selected").val();
		    	if(selVal == "1"){
		    		$("#refPrjNm").hide();
		    	}else {
                    $("#refPrjNm").show();
                }
			});

			$("#dkStyleCdUp").bind("change",function(){
				var selVal = $("#dkStyleCdUp option:selected").val();
				if(selVal == "1"){
					$("#refPrjNmUp").hide();
				}else {
                    $("#refPrjNmUp").show();
                }
			});

			$("#accTypCd").bind("change",function(){
		    	var selVal = $("#accTypCd option:selected").val();
		    	if(selVal == "1"){
		    		$("#accId-2").hide();
		    		$("#accId-3").hide();
		    	} else if(selVal == "2"){
		    		$("#accId-2").show();
		    		$("#accId-3").hide();
		    	} else if(selVal == "3"){
		    		$("#accId-2").hide();
		    		$("#accId-3").show();
		    	}else{
		    		$("#accId-2").hide();
		    		$("#accId-3").hide();
		    	}

		    	$("#accId-2-Id").val("");
				$("#accId-2").val("");
		    	$("#accId-3-Id").val("");
				$("#accId-3").val("");
			});

			$("#accTypCdUp").bind("change",function(){  
		    	var selVal = $("#accTypCdUp option:selected").val();
		    	if(selVal == "1"){
		    		$("#accId-2-Up").hide();
		    		$("#accId-3-Up").hide();
		    	}else if(selVal == "2"){
		    		$("#accId-2-Up").show();
		    		$("#accId-3-Up").hide();
		    	}else if(selVal == "3"){
		    		$("#accId-2-Up").hide();
		    		$("#accId-3-Up").show();
		    	}else{
		    		$("#accId-2-Up").hide();
		    		$("#accId-3-Up").hide();
		    	}
			});  
			
			$("#accId-2,#accId-2-Up").bind("click",function(){ 
				if($("#addBank_Html").attr("style") == ''){
			     	return;
			     } 
		    	ligerDialogBank =  $.ligerDialog.open({
		            width: 1050,
		            height:510,
		            top: 126,
		            title : '添加银行账户',
		            target: $("#addBank_Html"),
		            onHideDialog: function () {
		            	$("#addBank_Html").attr("style","display:none");
		              	clearLigerForm("searchBar_Bank");
		            } 
		          }); 
		         initGridBank();
			});
			
			$("#accId-3").bind("click",function(){
  		    	var selVal = $("#accTypCd option:selected").val();
  		    	if(selVal == "3"){
  		    		if ($("#refPrjId").val().length == 0) { 
  		    			$.ligerDialog.SQalert({content: '请选择一个再融资项目!',SQ_type: "success"});
  		    			return;
					}
		    	}
		    	
		    	if($("#addjgBank_Html").attr("style") == ''){
		     		return;
		     	}
		    	ligerDialogJgBank =  $.ligerDialog.open({
		            width: 1050,
		            height:510,
		            top: 126,
		            title : '添加银行账户',
		            target: $("#addjgBank_Html"),
		            onHideDialog: function () {
		            	$("#addjgBank_Html").attr("style","display:none");
		                //clearLigerForm("searchBar_Bank");
		            } 
		          }); 
		         initJgGridBank();
			}); 
			
			$("#accId-3-Up").bind("click",function(){
  		    	var selVal = $("#accTypCdUp option:selected").val();
  		    	if(selVal == "3"){
  		    		if ($("#refPrjIdUp").val().length == 0) { 
  		    			$.ligerDialog.SQalert({content: '请选择一个再融资项目!',SQ_type: "success"});
					}
		    	}
		    	
		    	if($("#addjgBank_Html").attr("style") == ''){
		     		return;
		     	}
		    	ligerDialogJgBank =  $.ligerDialog.open({
		            width: 1050,
		            height:510,
		            top: 126,
		            title : '添加银行账户',
		            target: $("#addjgBank_Html"),
		            onHideDialog: function () {
		            	$("#addjgBank_Html").attr("style","display:none");
		              	//clearLigerForm("searchBar_Bank");
		            } 
		          }); 
		          initJgGridBank();
			});
			
		     $("#refPrjNm").bind("click",function(){ 
		     	if($("#addPrj_Html").attr("style") == ''){
		     		return;
		     	}
		    	ligerDialogPrj =  $.ligerDialog.open({
		            width: 900,
		            height:500,
		            top: 100,
		            title : '添加项目',
		            target: $("#addPrj_Html"),
		            onHideDialog: function () {
		              $("#addPrj_Html").attr("style","display:none");
		              clearLigerForm("searchBarPrj");
		            } 
		          });
		          initGridPrj();
			});
			
			 $("#refPrjNmUp").bind("click",function(){  
			 	if($("#addPrj_Html").attr("style") == ''){
		     		return;
		     	}
			 	ligerDialogPrj =  $.ligerDialog.open({
		            width: 900,
		            height:500,
		            top: 100,
		            title : '添加项目',
		            target: $("#addPrj_Html"),
		            onHideDialog: function () {
		              $("#addPrj_Html").attr("style","display:none");
		              clearLigerForm("searchBarPrj");
		            } 
		          }); 
		          initGridPrj();
			});
			
			$("#searchBtnPrj").bind("click",function(){  
				var form = new liger.get("searchBarPrj");
		        var data = form.getData();
		        for (name in data){
		           gridPrj.setParm(name,data[name]);
		        };
		       gridPrj.reload();
			});
			
			$("#selectBtnPrj").bind("click",function(){  
				var selectedRows = gridPrj.getSelectedRows();
				if(selectedRows.length !=1){
					$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warring"});
					return;
				}
				var id = selectedRows[0].id;
				var fncprjnm = selectedRows[0].fncprjnm;
				var fncinsid = selectedRows[0].fncinsid;
				var selVal = "";
				if(isUpdateFlag == "modify"){
					$("#refPrjIdUp").val(id);
					$("#refPrjNmUp").val(fncprjnm);
					$("#jgNoIdUp").val(fncinsid);
					selVal = $("#accTypCdUp option:selected").val();
				}else{
					$("#refPrjId").val(id);
					$("#jgNoId").val(fncinsid);
					$("#refPrjNm").val(fncprjnm);
					selVal = $("#accTypCd option:selected").val();
				}
				if(ligerDialogPrj != null ){
					ligerDialogPrj.hidden();
				}
				
		    	if(selVal == "3"){
		    	    $("#accId-3").click();
		    	    $.ligerDialog.warn('重新选择再融资项目后，收款账户为机构账户时请重新选择账户信息，否则账户信息有误!')
		    	} 
			});
			
			$("#selectBtn_bank").bind("click",function(){  
				var selectedRows = grid_bank.getSelectedRows();
				if(selectedRows.length !=1){
					$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warring"});
					return;
				}
				var id = selectedRows[0].id;
				var bkNm = selectedRows[0].accNm;
				var bkNo = selectedRows[0].accNo;// 账户号
				if(isUpdateFlag == "modify"){
					var selVal = $("#accTypCdUp option:selected").val();
					if(selVal == "2"){
						$("#accId-2-Id-Up").val(id);
						$("#accId-2-Up").val(bkNo);
					}
					//$("#add_accTypCd").val(selectedRows[0].accTypCd);//  账户类型 ：我司账户（和机构账户不一样）默认都是对公，后台也设置  
					$("#up_bkNm").val(selectedRows[0].sysBkInfoVO.bkNm);// 开户行名
					$("#up_bkNo").val(selectedRows[0].sysBkInfoVO.bkNo);// 开户行号
					$("#up_rcptUnt").val(selectedRows[0].accNm); // 收款单位/人 -- 是账户名称 
				}else{
					var selVal = $("#accTypCd option:selected").val();
					if(selVal == "2"){
						$("#accId-2-Id").val(id);
						$("#accId-2").val(bkNo);
					}
					//$("#add_accTypCd").val(selectedRows[0].accTypCd);//  账户类型 ：我司账户（和机构账户不一样）默认都是对公，后台也设置  
					$("#add_bkNm").val(selectedRows[0].sysBkInfoVO.bkNm);// 开户行名
					$("#add_bkNo").val(selectedRows[0].sysBkInfoVO.bkNo);// 开户行号
					$("#add_rcptUnt").val(selectedRows[0].accNm); // 收款单位/人 -- 是账户名称 
				}
				
				if(ligerDialogBank != null ){
					ligerDialogBank.hidden();
				}
			});
			
			$("#selectBtn_jg_bank").bind("click",function(){  
				var selectedRows = jg_grid_bank.getSelectedRows();
				if(selectedRows.length !=1){
					$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warring"});
					return;
				}
				var id = selectedRows[0].id;
				var bkNm = selectedRows[0].banAccNm; 
				var accNum = selectedRows[0].accNum; // 账户号
				if(isUpdateFlag == "modify"){
					var selVal = $("#accTypCdUp option:selected").val();
					if(selVal == "3"){
						$("#accId-3-Id-Up").val(id);
						$("#accId-3-Up").val(accNum);
					}
					$("#up_accTypCd").val(selectedRows[0].pubVerPriCd); //  账户类型 ：对公 对私 
					$("#up_bkNm").val(selectedRows[0].banAccNm); // 开户行名
					$("#up_bkNo").val(selectedRows[0].banAccNum); // 开户行号
					$("#up_rcptUnt").val(selectedRows[0].accNm); // 收款单位/人 -- 是账户名称 
				}else{
					var selVal = $("#accTypCd option:selected").val();
					if(selVal == "3"){
						$("#accId-3-Id").val(id);
						$("#accId-3").val(accNum);
					}
					$("#add_accTypCd").val(selectedRows[0].pubVerPriCd); //  账户类型 ：对公 对私 
					$("#add_bkNm").val(selectedRows[0].banAccNm); // 开户行名
					$("#add_bkNo").val(selectedRows[0].banAccNum); // 开户行号
					$("#add_rcptUnt").val(selectedRows[0].accNm); // 收款单位/人 -- 是账户名称 
				}
				if(ligerDialogJgBank != null ){
					ligerDialogJgBank.hidden();
				}
			});
			
			$("#searchBtn_bank").bind("click",function(){  
		         var form = liger.get("searchBar_Bank");
		         var data = form.getData();
		         for (name in data){
		            grid_bank.setParm(name,data[name]);
		         };
		        grid_bank.reload();
		    });
		    /*******添加规则js end *************/
		    
		    /*****添加项目 js start *****/
			initDataPrj();//初始化数据
			initcombobox();
			/*******添加项目 js end ***/
        
			$("#totalMaxQty,#singleMaxQty,#startOvedayDays,#endOvedayDays,#totalMaxQtyUp,#singleMaxQtyUp,#startOvedayDaysUp,#endOvedayDaysUp").bind("blur",function(){ 
				if($(this).val() == ''){
					return;
				}
				
				var test = '';
				var idValue = $(this).attr("id");
				if(idValue == 'totalMaxQty' || idValue == 'totalMaxQtyUp'){
					test = '最高垫款次数 要求 >=0 的整数（累计）';
				}else if(idValue == 'singleMaxQty' || idValue == 'singleMaxQtyUp'){
					test = '最高垫款次数 要求 >=0 的整数（单资产）';
				}else if(idValue == 'startOvedayDays' || idValue == 'startOvedayDaysUp'){
					test = '起垫逾期天数 要求 >=0 的整数';
				}else if(idValue == 'endOvedayDays' || idValue == 'endOvedayDaysUp'){
					test = '最高逾期天数 要求 >=0 的整数';
				}
				
				if(!isNumber($(this).val()) && test != ''){
					$.ligerDialog.SQalert({content: test, SQ_type: "warring"});
				}
			});
			
		});
		
		/*******规则列表 js start *************/
		function clearBtn(){
		    $("#searchBar").ligerForm();
			var form = new liger.get("searchBar");
			form.setData({
				refPrjNm:" ",
				ruleNm:" "
			 });
		 }
		 
		//初始化列表
		function initGrid(){
			var params = {};
			var timestamp=new Date().getTime(); 
			grid = $("#grid").ligerGrid({
		    	url: '<%=path%>/dk/dkruleinfo/initList.do?timestamp = ' + timestamp,
		    	method : 'get',
		    	parms:params,
		        columns: [
  	            	{ display: '规则编号', name: 'ruleNo', minWidth: 80 ,align:'center',enabledSort:true},
		            { display: '规则名称', name: 'ruleNm', minWidth: 80 ,align:'center',enabledSort:true},
		            { display: '生效再融资项目', name: 'refPrjNm', minWidth: 120 ,align:'left',
  	            		render: function (rowdata, rowindex, value, column) {
		            			//明垫时	再融资项目不展示
								if(rowdata.dkStyleCd == '1') {
									return '';
								}else {
									var h='<a class="sq-button-hasicon" href="javascript:detailBtn(';
									h+="'"+rowdata.refPrjId+"'";
									h+=')">'+value+'</a>';
									return h;
								}
  	            			},
  	            	enabledSort:true}, 
	             	{ display: '垫款状态', name: 'certNo', minWidth: 80 ,align:'center',
  	            		render: function (rowdata, rowindex, value, column) { 
		  	            		if(rowdata.billStsCd == "0"){
		  	            			return '已执行';
		  	            		}else{
		  	            			return '未执行';
		  	            		}
  	            			},
  	            	enabledSort:true}, 
	  	            { display: '状态', name: 'ruleStsCd', minWidth: 80 ,align:'center',
  	            		render: function (rowdata, rowindex, value, column) { 
	  	            		var h = '';
	  	            		if(value=='1'){
	  	            		    h='正常';
	  	            		}else{
	  	            			h='作废';
	  	            		}
	  	                        return h;
	  	            		},
  	            	enabledSort:true},
	  	            { display: '垫款类型', name: 'dkStyleCd', minWidth: 80 ,align:'center',
  	            		render: function (rowdata, rowindex, value, column) {
	  	            		var h = '';
	  	            		if(value=='1'){
	  	            		    h='明垫';
	  	            		}else if(value=='0'){
	  	            			h='暗垫';
	  	            		}
	  	                        return h;
	  	            		},
  	            	enabledSort:true},
		            { display: '添加时间', name: 'crtTm', minWidth: 60,align:'center',render:renderDate, enabledSort:true}, 
		            { display: '添加人', name: 'crtUsrNm', minWidth: 80,align:'center',enabledSort:true}, 	
		            { display: '操作',isSort: false,width: 300,align:'center',
		                render: function (rowdata, rowindex, value){
		                  		var h='';
								//BILL_STS_CD	垫款单状态（0、结束(已执行)，1、垫款中(未执行)）
								//RULE_STS_CD 规则状态 :0、作废 1、正常
			                    if(rowdata.billStsCd == "0" || rowdata.ruleStsCd != "1"){
		  	            			h+='<span style="color:#AAAAAA;" class="sq-button-hasicon"><i class="sqBtnIco_4"></i>修改</span>';
		  	            		}else{
		  	            			h+='<a class="sq-button-hasicon" href="javascript:toMfrModify(';
			            			h+="'"+rowdata.id+"'";
			                    	h+=')"><i class="sqBtnIco_4"></i>修改</a>';
		  	            		}
		  	            		
		  	            		var z= '';
								if(rowdata.ruleStsCd == "1" ){
									z+='<a class="sq-button-hasicon" href="javascript:updateIsRuleStsCd(';
				            		z+="'"+rowdata.id+"'";
				            		z+=",'"+rowdata.billStsCd+"'";
				                    z+=')"><i class="sqBtnIco_4"></i>作废</a>';
								}else{
									z+='<span style="color:#AAAAAA;" class="sq-button-hasicon" ><i class="sqBtnIco_4"></i>作废</span>';
								}
			                    
			                    var d='<a class="sq-button-hasicon" href="javascript:toRuleInfoDetail(';
			            			d+="'"+rowdata.id+"'";
			                    	d+=')"><i class="sqBtnIco_4"></i>详情</a>';
			                    
			                    var s='';
			                    if(rowdata.ruleStsCd == "1" ){
				                    s+='<a class="sq-button-hasicon" href="javascript:addBillInfo(';
			            			s+="'"+rowdata.id+"'";
			                    	s+=')"><i class="sqBtnIco_4"></i>生成垫付单</a>'; 
								}else{
									s+='<span style="color:#AAAAAA;" class="sq-button-hasicon" ><i class="sqBtnIco_4"></i>生成垫付单</span>';
								}
			                    
		                    return h + d + z + s ;
		                }
		            }  
		        ],
		        pageSize:10,
		        root:'rows',
		        record:'total',
		        hideLoadButton : true,
		        width: '100%',
		        height:'100%',
		        heightDiff:-2,
		        allowUnSelectRow: true,
	            alternatingRow: true,
		        rownumbers:true,
		        enabledEdit: true,
		    });
			grid.setHeight(500);
			$("#searchBar").ligerForm();
		}
		
		function detailBtn(id){
			Add_navTab('tab_project_detail'+id,'项目基本信息详情','<%=path%>/rfbuss/fncprjbscinfo/toDetailPage1.do?id='+id);
		}
		/*******规则列表 js end *************/
		
	    /*******添加规则js start *************/
		//添加规则信息
		function addBtn(){
			$("#ruleNm").val("");
	        $("#refPrjId").val("");
	        $("#jgNoId").val("");
	        $("#refPrjNm").val("");
	        $("#accTypCd").val("");
	        $("#accId-2-Id").val("");
	        $("#accId-2").val("");
	        $("#accId-2").hide();
	        $("#accId-3-Id").val("");
	        $("#accId-3").val("");
	        $("#accId-3").hide();
	        $("#add_accTypCd").val("");
			$("#add_bkNm").val("");
			$("#add_bkNo").val("");
			$("#add_rcptUnt").val("");
	                        	
	        $("#totalMaxQty").removeAttr("disabled");
            $("#totalMaxQty").val("");
	        $("#totalMaxQtyCh").removeAttr("checked");
	        
	        $("#singleMaxQty").removeAttr("disabled");
	        $("#singleMaxQty").val("");
	        $("#singleMaxQtyCh").removeAttr("checked");
	        $("#ransomExecCd").val("");

	        $("#dkStyleCd").val("");
	        $("#isAssBiz").val("");
	        $("#thdOrgCd").val("  ");
            $("#lsDtStart").ligerGetDateEditorManager().setValue('');
            $("#lsDtEnd").ligerGetDateEditorManager().setValue('');

	        $("#startOvedayDays").val("");
	        $("#endOvedayDays").val("");
	        
			isUpdateFlag = "add";		
			ligerDialogAdd =  $.ligerDialog.open({
	            width: 900,
	            height:420,
	            top: 5,
	            title : '添加规则',
	            target: $("#addRule_Html"),
	            onHideDialog: function () {
	                clearLigerForm("dk_rule_info_form");
	            }
	          });
		}
		
		function saveDkRuleInfo() {
			if($("#ruleNm").val() == ''){
				$.ligerDialog.SQalert({content:'请输入规则名称', SQ_type: "warring"});
				return;
			}
			if($("#ruleNm").val().length > 30){
				$.ligerDialog.SQalert({content:'规则名称要求30字内', SQ_type: "warring"});
				return;
			}

            if($("#dkStyleCd").val() == ''){
                $.ligerDialog.SQalert({content:'请选择垫款类型', SQ_type: "warring"});
                return;
            }else {
                if($("#dkStyleCd").val() == '0') {
                    if($("#refPrjId").val() == ''){
                        $.ligerDialog.SQalert({content:'请选择再融资项目', SQ_type: "warring"});
                        return;
                    }
                }
            }

			if($("#accTypCd").val() == ''){
				$.ligerDialog.SQalert({content:'请选择收款账户', SQ_type: "warring"});
				return;
			}else{
				var selVal = $("#accTypCd option:selected").val();
		    	if(selVal == "2"){
					if($("#accId-2").val() == ''){
						$.ligerDialog.SQalert({content:'请选择银行账户', SQ_type: "warring"});
						return;
					}
		    	} else if(selVal == "3"){
		    		if($("#accId-3").val() == ''){
						$.ligerDialog.SQalert({content:'请选择银行账户', SQ_type: "warring"});
						return;
					}
		    	}
			}
			
			if(!$("#totalMaxQtyCh").is(':checked')){
				if($("#totalMaxQty").val() == ''){
					$.ligerDialog.SQalert({content:'请输入最高垫款次数（累计）', SQ_type: "warring"});
					return;
				}else{
					if(!isNumber($("#totalMaxQty").val())){
						$.ligerDialog.SQalert({content:'最高垫款次数 要求 >=0 的整数（累计）', SQ_type: "warring"});
						return;
					}
				}
			}
			
			if(!$("#singleMaxQtyCh").is(':checked')){
				if($("#singleMaxQty").val() == ''){
					$.ligerDialog.SQalert({content:'请输入最高垫款次数（单资产）', SQ_type: "warring"});
					return;
				}else{
					if(!isNumber($("#singleMaxQty").val())){
						$.ligerDialog.SQalert({content:'最高垫款次数 要求 >=0 的整数（单资产）', SQ_type: "warring"});
						return;
					}
				}
			}
			
			if($("#ransomExecCd").val() == ''){
				$.ligerDialog.SQalert({content:'请选择赎回执行', SQ_type: "warring"});
				return;
			}

            if($("#isAssBiz").val() == ''){
                $.ligerDialog.SQalert({content:'请选择是否资管业务', SQ_type: "warring"});
                return;
            }else {
                var selVal = $("#isAssBiz option:selected").val();
                if(selVal == "1") {
                    if($("#thdOrgCd").val() == '  '){
                        $.ligerDialog.SQalert({content:'请选择第三方机构', SQ_type: "warring"});
                        return;
                    }
                }
            }


			if($("#startOvedayDays").val() == ''){
				$.ligerDialog.SQalert({content:'请输入起垫逾期天数', SQ_type: "warring"});
				return;
			}else{
				if(!isNumber($("#startOvedayDays").val())){
					$.ligerDialog.SQalert({content:'起垫逾期天数 要求 >=0 的整数', SQ_type: "warring"});
					return;
				}
			}
			
			if($("#endOvedayDays").val() == ''){
				$.ligerDialog.SQalert({content:'请输入最高逾期天数', SQ_type: "warring"});
				return;
			}else{
				if(!isNumber($("#endOvedayDays").val())){
					$.ligerDialog.SQalert({content:'最高逾期天数 要求 >=0 的整数', SQ_type: "warring"});
					return;
				}
			}

			if(Number($("#startOvedayDays").val()) > Number($("#endOvedayDays").val())){
				$.ligerDialog.SQalert({content:'最高逾期天数 >= 起垫逾期天数 ', SQ_type: "warring"});
				return;
			}
			
			var jsonData = $("#dk_rule_info_form").serializeArray();
			var url = '<%=path%>/dk/dkruleinfo/add.do';
	       	$.ajax({
	            type: 'post',
	            dataType: 'json',
	            data: jsonData,
	            url: url,
	            success: function (msg) {
	            	/*if(msg.data == 'true'){
	            		$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
	            		grid.reload();
	            		if(ligerDialogAdd != null ){
							ligerDialogAdd.hidden();
						}
	            	}*/
	            	if(msg.success == 1){
	            		$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
	            		grid.reload();
	            		if(ligerDialogAdd != null ){
							ligerDialogAdd.hidden();
						}
	            	}else if(msg.success == 0) {
						$.ligerDialog.SQalert({content: msg.info,SQ_type: "warring"});
						/*grid.reload();
						if(ligerDialogAdd != null ){
							ligerDialogAdd.hidden();
						}*/
					}
	            }
	        }); 
     }
     
     function saveDkRuleInfoUp() {
     		if($("#ruleNmUp").val() == ''){
				$.ligerDialog.SQalert({content:'请输入规则名称', SQ_type: "warring"});
				return;
			}
			if($("#ruleNmUp").val().length > 30){
				$.ligerDialog.SQalert({content:'规则名称要求30字内', SQ_type: "warring"});
				return;
			}
			
			if($("#accTypCdUp").val() == ''){
				$.ligerDialog.SQalert({content:'请选择收款账户', SQ_type: "warring"});
				return;
			}else{
				var selVal = $("#accTypCdUp option:selected").val();
		    	if(selVal == "2"){
					if($("#accId-2-Up").val() == ''){
						$.ligerDialog.SQalert({content:'请选择银行账户', SQ_type: "warring"});
						return;
					}
		    	} else if(selVal == "3"){
		    		if($("#accId-3-Up").val() == ''){
						$.ligerDialog.SQalert({content:'请选择银行账户', SQ_type: "warring"});
						return;
					}
		    	}
			}
			
			if(!$("#totalMaxQtyChUp").is(':checked')){
				if($("#totalMaxQtyUp").val() == ''){
					$.ligerDialog.SQalert({content:'请输入最高垫款次数（累计）', SQ_type: "warring"});
					return;
				}else{
					if(!isNumber($("#totalMaxQtyUp").val())){
						$.ligerDialog.SQalert({content:'最高垫款次数 要求 >=0 的整数（累计）', SQ_type: "warring"});
						return;
					}
				}
			}
			
			if(!$("#singleMaxQtyChUp").is(':checked')){
				if($("#singleMaxQtyUp").val() == ''){
					$.ligerDialog.SQalert({content:'请输入最高垫款次数（单资产）', SQ_type: "warring"});
					return;
				}else{
					if(!isNumber($("#singleMaxQtyUp").val())){
						$.ligerDialog.SQalert({content:'最高垫款次数 要求 >=0 的整数（单资产）', SQ_type: "warring"});
						return;
					}
				}
			}
			
			if($("#ransomExecCdUp").val() == ''){
				$.ligerDialog.SQalert({content:'请选择赎回执行', SQ_type: "warring"});
				return;
			}

			 if($("#dkStyleCdUp").val() == ''){
				 $.ligerDialog.SQalert({content:'请选择垫款类型', SQ_type: "warring"});
				 return;
			 }else {
			 	if($("#dkStyleCdUp").val() == '0') {
					if($("#refPrjIdUp").val() == ''){
						$.ligerDialog.SQalert({content:'请选择再融资项目', SQ_type: "warring"});
						return;
					}
				}
			 }

			 if($("#isAssBizUp").val() == ''){
				 $.ligerDialog.SQalert({content:'请选择是否资管业务', SQ_type: "warring"});
				 return;
			 }

			 if($("#isAssBizUp").val() == ''){
				 $.ligerDialog.SQalert({content:'请选择是否资管业务', SQ_type: "warring"});
				 return;
			 }else {
				 var selVal = $("#isAssBizUp option:selected").val();
				 if(selVal == "1") {
					 if($("#thdOrgCdUp").val() == '  ') {
						 $.ligerDialog.SQalert({content:'请选择第三方机构', SQ_type: "warring"});
						 return;
					 }
				 }
			 }

				
			if($("#startOvedayDaysUp").val() == ''){
				$.ligerDialog.SQalert({content:'请输入起垫逾期天数', SQ_type: "warring"});
				return;
			}else{
				if(!isNumber($("#startOvedayDaysUp").val())){
					$.ligerDialog.SQalert({content:'起垫逾期天数为 要求 >=0 的整数', SQ_type: "warring"});
					return;
				}
			}
			
			if($("#endOvedayDaysUp").val() == ''){
				$.ligerDialog.SQalert({content:'请输入最高逾期天数', SQ_type: "warring"});
				return;
			}else{
				if(!isNumber($("#endOvedayDaysUp").val())){
					$.ligerDialog.SQalert({content:'最高逾期天数 要求 >=0 的整数', SQ_type: "warring"});
					return;
				}
			}
			
			if(Number($("#startOvedayDaysUp").val()) > Number($("#endOvedayDaysUp").val())){
				$.ligerDialog.SQalert({content:'最高逾期天数 >= 起垫逾期天数 ', SQ_type: "warring"});
				return;
			}
			
	        var jsonData = $("#changeRule_form").serializeArray();
			var url = '<%=path%>/dk/dkruleinfo/modify.do?id='+modifyId;
	       	$.ajax({
	            type: 'post',
	            dataType: 'json',
	            data: jsonData,
	            url: url,
	            success: function (msg) {
	           		if(msg.success == '1'){
	            		$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
	            		grid.reload();
	            		if(ligerDialogUp != null ){
							ligerDialogUp.hidden();
						}
	            	}else{
	            		$.ligerDialog.SQalert({content: msg.info,SQ_type: "warring"});
	            	}
	            }
	        }); 
     }
     
     function cancelDkRuleINfoBtn(){
     	ligerDialogAdd.hidden();
     }
     
     function cancelDkRuleINfoUpBtn(){
     	ligerDialogUp.hidden();
     }
     
     function toRuleInfoDetail(id){
		var callback = function(){
		}
		var timestamp=new Date().getTime(); 
		Add_navTab( 'dk_dkruleinfo_RuleINfo'+timestamp,'垫付规则详情','<%=path%>/dk/dkruleinfo/toRuleInfoDetail.do?id='+id,callback); 
     }
	/*******添加规则js end  *************/
		
	/*******添加项目 js start  *************/
	//初始化数据
    function initDataPrj(){
    	initFormPrj();//初始化表单
    }
	//初始化表单
    function initFormPrj(){
    	$("#searchBarPrj").ligerForm({
			validate: true
		});   
		$("#searchBarPrj").check_ligerFormEditor();//重新刷新页面动态字段
	};
	
	//初始化列表
	function initGridPrj(){
		var params = {};
		var timestamp=new Date().getTime(); 
		$("#gridPrj").ligerGrid({
	    	url: '<%=path%>/rfbuss/fncprjbscinfo/initList.do?timestamp='+timestamp,
	    	method : 'get',
	    	parms:params,
	        columns: [
	            { display: '项目状态', name: 'fncprjstNM', minWidth: 140 ,enabledSort:true},  
	            { display: '融资机构', name: 'fncinsNM', minWidth: 140 , enabledSort:true}, 
	            { display: '融资报价', name: 'fncscmNM', minWidth: 140 , enabledSort:true},
	            { display: '项目编号', name: 'fncprjid', minWidth: 140 , render: function (rowdata, rowindex, value, column) { 
	            		var h = '';
	            			if(value&&value!="null"){
	            		    h+='<a href="javascript:detailBtn(';
	                        h+="'"+rowdata.id+"'";
	                        h+=')">'+value+'</a>'
	            			}
	                        return h;
	            		},
	            	enabledSort:true}, 
	            { display: '项目名称', name: 'fncprjnm', minWidth: 200 , enabledSort:true}
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:true,
	        allowUnSelectRow: true,
            alternatingRow: true,
	        rownumbers:true,
	        enabledEdit: true,
	    });
		gridPrj = liger.get("gridPrj");
		gridPrj.setHeight(500);
	   	$("#searchBarPrj").ligerForm();
	}
	
	var frilist = [];
	<c:if test="${not empty frilist}"> frilist = ${frilist}; </c:if>
    function initcombobox(){
		  var combobox=  $("#fncinsid").ligerComboBox({
	    	     data:frilist,
	             selectBoxWidth: 270,
	             selectBoxHeight: 150,
	             valueField: "id",
	             textField: "fundRasInsNm",
	             });
		  
		  $("#prjstcd").ligerComboBox({
    		   url:'<%=path%>/rfbuss/fncprjbscinfo/getStcdList.do',
			        ajaxType :'GET', 
    	          selectBoxWidth: 270,
    	          selectBoxHeight: 150,
    		      valueField: "key", 
    		      textField: "value",
    		     }); 
	 }
	 
	function clearBtnPrj(){
   		$("#searchBarPrj").ligerForm();
		var form = new liger.get("searchBarPrj");
		form.setData({
			fncinsid:"",
			fncprjnm:"",
			prjstcd:"",
		 });
	}
	/*******添加项目 js end *******/
	
	/*******添加银行 js start******/
	//初始化列表
	function initGridBank(){
		var params = {};
		var timestamp=new Date().getTime(); 
	   	grid_bank = $("#grid_bank").ligerGrid({
	        url: '<%=path%>/system/sysBkAccInfo/initList.do?timestamp='+timestamp,
	        method : 'get',
	        columns: [
				{ display: '开户行', name: 'bkNm', width: 250},
	            { display: '账户名称', name: 'accNm', width: 250, enabledSort:true},
	            { display: '账号', name: 'accNo', width: 250, enabledSort:true},
	            { display: '账号类型', name: 'accTypNm', minWidth: 100, enabledSort:true},
	            { display: '状态', name: 'isOpen', minWidth: 100 , enabledSort:true},
	            { display: '账号备注', name: 'accRem', minWidth: 140, enabledSort:true}
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height: 400,
	        heightDiff: -2,
	        checkbox:true,
	        allowUnSelectRow:true,
	        alternatingRow: false
    	});
		grid_bank.setHeight(500);
	   	$("#searchBar_Bank").ligerForm();
	}
	
	 //初始化机构银行列表
	function initJgGridBank(){
		// 沒有机构不查询 
		var jgNoId = '';
		if(isUpdateFlag == "modify"){
			jgNoId =  $("#jgNoIdUp").val();
		}else{
			jgNoId =  $("#jgNoId").val();
		}
		if (jgNoId.length == 0) { 
			return;
		}
		var params = {fundRasInsId:jgNoId};
		var timestamp=new Date().getTime(); 
	   	jg_grid_bank = $("#jg_grid_bank").ligerGrid({
	        url: '<%=path%>/dk/dkruleinfo/initJGBankkList.do?timestamp='+timestamp,
	        method : 'get',
	        parms:params,
	        columns: [
	        	{ display: '账户用途', name: 'accTypCdNm', minWidth: 150,align: 'left', enabledSort:true },
	        	{ display: '账户类型', name: 'pubVerPriCd', minWidth: 50 , render: function (rowdata, rowindex, value, column) { 
	            			if(value == "0"){
	            				return '对公';
	            			}else if(value == "1"){
	            				return '对私';
	            			}
	                        return '';
	            		},
	            	enabledSort:true},
				{ display: '银行名称', name: 'banAccNm', minWidth: 150,align: 'left', enabledSort:true },
				{ display: '行号', name: 'banAccNum', minWidth: 150, enabledSort:true},
				{ display: '户名', name: 'accNm', minWidth: 200 , enabledSort:true},
				{ display: '账号', name: 'accNum', minWidth: 100 , enabledSort:true},
				{ display: '账号备注', name: 'rem', minWidth: 100 , enabledSort:true}
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height: 400,
	        heightDiff: -2,
	        checkbox:true,
	        allowUnSelectRow:true,
	        alternatingRow: false
    	});
		jg_grid_bank.setHeight(500);
	}	
	/*******添加银行 js start*******/
	
	/*******修改规则  js start******/
	function toMfrModify(id){
		isUpdateFlag = "modify";
		modifyId = id;
		if(!id)return;
		$.ajax({
			type: 'get',
			dataType:'json',
			data:{id:id},
			url: '<%=path%>/dk/dkruleinfo/getById.do',
			success:function(msg){
				if(msg.success == 1){
					openChange();//弹出修改框
					setData(msg.data);//设置数据
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		});
	}

	function updateIsRuleStsCd(id,billStatus){
		if(billStatus == "1"){
			$.ligerDialog.SQalert({content: '该垫款规则存在正在执行垫款单，请完成后再行作废!',SQ_type: "error"});
			return;
		}
		if(!id)return;
		$.ajax({
			type: 'get',
			dataType:'json',
			data:{id:id},
			url: '<%=path%>/dk/dkruleinfo/updateIsRuleStsCd.do',
			success:function(msg){
				if(msg.success == '1'){
					 $.ligerDialog.SQalert({content: '处理成功',SQ_type: "success"});
					 grid.reload();
            	}else{
            		$.ligerDialog.SQalert({content: msg.info,SQ_type: "warring"});
            	}
			}	
		});
	}  

	function toMfrModify(id){
			isUpdateFlag = "modify";
			modifyId = id;
			if(!id)return;
			$.ajax({
				type: 'get',
				dataType:'json',
				data:{id:id},
				url: '<%=path%>/dk/dkruleinfo/getById.do',
				success:function(msg){
					if(msg.success == 1){
						openChange();//弹出修改框
						setData(msg.data);//设置数据
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		}
	
	function addBillInfo(ruleId){
		if(!ruleId)return;
		$.ajax({
			type: 'post',
			dataType:'json',
			data:{ruleId:ruleId},
			url: '<%=path%>/dk/dkbillinfo/add.do',
			success:function(msg){
				if(msg.success == '1'){
					var callback = function(){
					}
					var timestamp=new Date().getTime(); 
					Add_navTab( 'dk_billInfo_list'+ruleId,'垫付单列表','<%=path%>/dk/dkbillinfo/toListPage.do?timestamp='+timestamp,callback); 
				}else{
					$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				}
			}
		});
	}
	
	function openChange(){
		ligerDialogUp = $.ligerDialog.open({
	        width: 900,
            height:420,
            top: 5,
	        title : '修改规则',
	        target: $("#changeRule_Html"),
	        onHideDialog: function () {
	            clearLigerForm("changeRule_form");
	        }
	    });
	} 

	//设置页面数据
	function setData(data){
		$("#ruleNmUp").val(data.ruleNm);
		$("#refPrjIdUp").val(data.refPrjId);
		$("#refPrjNmUp").val(data.refPrjNm);
		$("#accTypCdUp").val(data.accTypCd);
		$("#ransomExecCdUp").val(data.ransomExecCd);

        $("#dkStyleCdUp").val(data.dkStyleCd);
		$("#isAssBizUp").val(data.isAssBiz);
		$("#lsDtStartUp").ligerGetDateEditorManager().setValue(data.lsDtStart);
        $("#lsDtEndUp").ligerGetDateEditorManager().setValue(data.lsDtEnd);
		//$("#thdOrgCdUp option[value= " + "'" + data.thdOrgCd + "_" + data.thdOrgId + "'" + "]").attr("selected",true);
		if(data.thdOrgCd == null || data.thdOrgCd == "" || data.thdOrgCd == '') {
			$("#thdOrgCdUp").val("'" + "_" + data.thdOrgId + "'")
		}else {
			$("#thdOrgCdUp").val("'" + data.thdOrgCd + "_" + data.thdOrgId + "'")
		}

		$("#startOvedayDaysUp").val(data.startOvedayDays);
		$("#endOvedayDaysUp").val(data.endOvedayDays);
		
		$("#up_accTypCd").val(data.bkAccTypCd);
		$("#up_bkNm").val(data.payeeBkNm);
		$("#up_bkNo").val(data.payeeBkNo);
		$("#up_rcptUnt").val(data.accNm);

        var dkStyleCd = data.dkStyleCd;
        if(dkStyleCd == "1"){
            $("#refPrjNmUp").hide();
        }else {
            $("#refPrjNmUp").show();
        }

		if(data.totalMaxQty == "-1"){
		  	$("#totalMaxQtyChUp").attr("checked",'true'); 
		  	$("#totalMaxQtyUp").val("");
	    	$("#totalMaxQtyUp").attr("disabled","disabled");
		}else{
			$("#totalMaxQtyUp").val(data.totalMaxQty);
			$("#totalMaxQtyChUp").removeAttr("checked"); 
			$("#totalMaxQtyUp").removeAttr("disabled");
		}
		
		if(data.singleMaxQty == "-1"){
		  	$("#singleMaxQtyChUp").attr("checked",'true'); 
		  	$("#singleMaxQtyUp").val("");
	    	$("#singleMaxQtyUp").attr("disabled","disabled");
		}else{
			$("#singleMaxQtyUp").val(data.singleMaxQty);
			$("#singleMaxQtyChUp").removeAttr("checked"); 
			$("#singleMaxQtyUp").removeAttr("disabled");
		}


		var accTypCd = data.accTypCd;
		 if(accTypCd == "2"){
    		$("#accId-2-Up").show();
    		$("#accId-3-Up").hide();
    		$("#accId-2-Id-Up").val(data.accId);
    		$("#accId-2-Up").val(data.accNum);

    		$("#accId-3-Id-Up").val("");
    		$("#accId-3-Up").val("");
    	}
    	if(accTypCd == "3"){
    		$("#accId-2-Up").hide();
    		$("#accId-3-Up").show();
    		$("#accId-3-Id-Up").val(data.accId);
    		$("#accId-3-Up").val(data.accNum);
    		
    		$("#accId-2-Up").val("");
    		$("#accId-2-Id-Up").val("");
    		// 查询机构号 
    		$.ajax({
				type: 'get',
				dataType:'json',
				data:{id:data.refPrjId},
				async:false, 
				url: '<%=path%>/dk/dkruleinfo/getPrjById.do',
				success:function(msg){
					if(msg.success == '1'){
						$("#jgNoIdUp").val(msg.data.fncinsid);
	            	}
				}	
			});
    	}
	}  

    //验证是否为正整数 
	function isNumber(value) {       
	    var patrn = /^(-)?\d+(\.\d+)?$/;
	    if (patrn.exec(value) == null || value == "") {
	        return false;
	    } else {
	    	if(Number.isInteger(Number(value))){
	    		 if(Number(value) < 0){
	    			return false;
		   		 }else{
		   		  	return true;
		   		 }
	    	}else{
	    		return false;
	    	}
	    }
	}
	
	function trim(str){ 
  		return str.replace(/(^\s*)|(\s*$)/g, ""); 
	}
	
	//格式化为人民币格式
	function renderAmt(rowdata, rowindex, value) {
        var h="￥" + FormatMoney(value)
        return h;
    }
	
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value&&value!=''){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
		
	</script>
</body>
</html>